package huawei;

import java.util.HashMap;
import java.util.Map;

/**
 * 9宫按键输入
 */
public class Q115 {

    static Map<Integer, char[]> map ;

    static {
        map = new HashMap<>();
        map.put(1, new char[] {',','.'});
        map.put(2, new char[] {'a', 'b', 'c'});
        map.put(3, new char[] {'d', 'e', 'f'});
        map.put(4, new char[] {'g', 'h', 'i'});
        map.put(5, new char[] {'j', 'k', 'l'});
        map.put(6, new char[] {'m', 'n', 'o'});
        map.put(7, new char[] {'p', 'q', 'r', 's'});
        map.put(8, new char[] {'t', 'u', 'v'});
        map.put(9, new char[] {'w', 'x', 'y', 'z'});
        map.put(0, new char[] {' '});
    }

    static boolean swap = false;

    public static void main(String[] args) {
//        String s = "2222/22";
//        String s = "#2222/22";
        String s = "#222233";
        if (s.charAt(s.length() - 1) != '/') {
            s += '/';
        }
        int i = 0;

        StringBuilder sb = new StringBuilder();
        while (i < s.length()) {
            if (s.charAt(i) == '#') {
                swap = !swap;
                i += 1;
                continue;
            }

            if (!swap) {
                // 数字输入
                if (s.charAt(i) != '/') {
                    sb.append(s.charAt(i));
                }

                i += 1;
                continue;
            }

            if (swap) {
                boolean is = false;
                for (int j = i + 1; j < s.length(); j++) {
                    if (s.charAt(j) == '/' || s.charAt(j) != s.charAt(j - 1)) {
                        int len = j - i;
                        char c = map.get(s.charAt(j - 1) - '0')[(len - 1) % map.get(s.charAt(j - 1) - '0').length];
                        sb.append(c);
                        if (s.charAt(j) == '/') {
                            i = j + 1;
                        } else {
                            i = j;
                        }
                        is = true;
                        break;
                    }
                }
                if (!is) {
                    sb.append(map.get(s.charAt(i) - '0')[0]);
                    i += 1;
                }
            }
        }

        System.out.println(sb.toString());
    }
}
